package com.sanbuTech.encrypt;

import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

public class HmacSHA1 {
	
	public static byte[] getHmacSHA1(String url, String secret_key) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException{
		    Mac mac = Mac.getInstance("HmacSHA1");  
		    SecretKeySpec secret = new SecretKeySpec(  
		    		secret_key.getBytes("UTF-8"), mac.getAlgorithm());  
		    mac.init(secret);  
		    return mac.doFinal(url.getBytes());
	}

}
